package com.example.common.utils;

/**
 * <p>
 *
 * </p>
 *
 * @author zyred
 * @since v 0.1
 **/
public class LuaScriptUtil {

    /**
     * 比较于删除 token 作为原子操作
     * @return  脚本语句  0：删除失败 1：对比成功，删除成功
     */
    public static String atomicOrderToken () {
        return "if redis.call('get', KEYS[1]) == ARGV[1] " +
                "then " +
                "   return redis.call('del', KEYS[1]) " +
                "else " +
                "   return 0 end";
    }

}
